using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 

public partial class RecruitManagement_JobCategories : System.Web.UI.Page
{
    string connectionString =
    WebConfigurationManager.ConnectionStrings[
    "RCVDB2000"].ConnectionString;
    SqlConnection sqlConnection;
    SqlCommand sqlCommand;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlConnection = new SqlConnection();
        sqlConnection.ConnectionString =
        connectionString;
        try
        {
            sqlConnection.Open();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText =
            "select * from tblJobCategories";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            SqlDataReader sqlDataReader
            = sqlCommand.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                 GridView1.DataSource = sqlDataReader;
                 GridView1.DataBind();
                 CreateLink(GridView1, 
                 "JobCategory.aspx",0,1);
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
        catch (Exception ex)
        {
            literalError.Text += "Failed:" + ex.Message;
        }
        sqlConnection.Dispose();
    }
    void CreateLink(GridView GridView1, 
    string url, int fieldIdIndex, 
    int fieldLinkIndex)
    {
        Common cls = new Common();
        foreach (GridViewRow 
        gridViewRow in GridView1.Rows)
        {
            HyperLink hyperLink = new HyperLink();
            hyperLink.Text = 
            gridViewRow.Cells[fieldLinkIndex].Text;
            hyperLink.NavigateUrl = url +
            "?ItemId=" + cls.RCVQueryStringEncrypting(
            gridViewRow.Cells[fieldIdIndex].Text);
            gridViewRow.Cells[1].Controls.Add(hyperLink);
        }
    }
}
